package io.jpress.pro.filesync;

import io.jboot.Jboot;
import io.jboot.app.config.annotation.ConfigModel;

@ConfigModel(prefix = "jpress.filesync.")
public class FileSyncConfig {

    /**
     * 是否启用 JPress 文件同步方案，默认不开启
     * 如果开启的话，建议让 Nginx 等前端屏蔽 /filesync 路径
     *
     *  若不开启，可以使用其他文件同步方案，比如：Linux 下的 Rsync+Inotify-tools 方案。又或者共享磁盘等。
     */
    private boolean enable = false;

    /**
     * 需要同步的服务节点，多个节点用分号隔开
     * 例如：127.0.0.1:8081;127.0.0.2:8082;127.0.0.3:8083
     */
    private String remoteHosts;


    /**
     * 远程端的文件同步路径
     */
    private String httpActionPath = "/filesync";



    /**
     * 通过什么协议进行同步的，默认 http 协议
     * 只支持 http 或者 https
     */
    private String httpScheme = "http";



    /**
     * 签名秘钥
     */
    private String secret ;

    /**
     * 是否同步 attachment 目录，也就是附件目录
     * 默认 false，一般情况下通过 attachmentManager 去做附件同步了
     */
    private boolean syncAttachmentDirEnable = false;


    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getRemoteHosts() {
        return remoteHosts;
    }

    public void setRemoteHosts(String remoteHosts) {
        this.remoteHosts = remoteHosts;
    }

    public String getHttpActionPath() {
        return httpActionPath;
    }

    public void setHttpActionPath(String httpActionPath) {
        this.httpActionPath = httpActionPath;
    }


    public String getHttpScheme() {
        return httpScheme;
    }

    public void setHttpScheme(String httpScheme) {
        this.httpScheme = httpScheme;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public boolean isSyncAttachmentDirEnable() {
        return syncAttachmentDirEnable;
    }

    public void setSyncAttachmentDirEnable(boolean syncAttachmentDirEnable) {
        this.syncAttachmentDirEnable = syncAttachmentDirEnable;
    }

    private static FileSyncConfig instance;

    public static FileSyncConfig getInstance(){
        if (instance == null){
            instance = Jboot.config(FileSyncConfig.class);
        }
        return instance;
    }
}
